﻿using BaseUI;
using BLL;
using Model;
using System;
using System.Data;
using System.Web.UI;

namespace Thksoft.BusinessExpansion.Process
{
    public partial class Business_Details : BasePage
    {
        private Qs_BusinessBLL qbb = new Qs_BusinessBLL();

        private static string pid = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string bid = Request.QueryString["N_business_id"].ToString();
                GetData(bid);
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GetData(string id)
        {
            DataTable dt = qbb.getBussinessById(id);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[0];
                Label1.Text = dr["业务名称"].ToString();
                Label4.Text = dr["所属流程"].ToString();
                Label6.Text = dr["操作人员"].ToString();
                Label5.Text = dr["业务状态"].ToString();
                Label7.Text = dr["操作时间"].ToString();
                Label3.Text = dr["公司名称"].ToString();

                Label2.Text = id;
            }

            DataTable dtTran = new Lc_TransactionBLL().GetTranByBidNew(id, lognUser.USER_NAME);
            grvShow.DataSource = dtTran;
            grvShow.DataBind();

            if (dt.Rows[0]["n_process_id"].ToString() == "121")
            {
                Control trol = Page.LoadControl("../../UserCotrols/CtrlYearFundsMX.ascx");
                PlaceHolder3.Controls.Add(trol);  //加载申请明细信息控件
            }
            else if (dt.Rows[0]["n_process_id"].ToString() == "51")
            {
                Control trol = Page.LoadControl("../../UserCotrols/CtrlMonthFundMX.ascx");
                PlaceHolder3.Controls.Add(trol);  //加载申请明细信息控件
            }
            else if (dt.Rows[0]["n_process_id"].ToString() == "50")
            {
                Control trol = Page.LoadControl("../../UserCotrols/CtrlWeekFundsMX.ascx");
                PlaceHolder3.Controls.Add(trol);  //加载申请明细信息控件
            }
            else if (dt.Rows[0]["n_process_id"].ToString() == "49")
            {
                Control trol = Page.LoadControl("../../UserCotrols/CtrlUrgentMX.ascx");
                PlaceHolder3.Controls.Add(trol);  //加载申请明细信息控件
            }
        }

        public string GetUserNames(string ids)
        {
            return new Sys_UserBLL().GetUserNameS(ids);
        }

        /// <summary>
        /// 通过队列 查找人员
        /// </summary>
        /// <param name="qid"></param>
        /// <returns></returns>
        public string GetUserByQuid(string qid)
        {
            Lc_Queue qModel = new Lc_QueueBLL().GetInfoById(qid);

            if (qModel.N_TRAN_TYPE == 0)
            {
                //人员办理
                return new Sys_UserBLL().GetUserNameS(qModel.C_QUEUE_TRANSACTION_ID);
            }
            else
            {
                //岗位办理
                return new Sys_RoleBLL().GetRoleNames(qModel.C_POSTS);
            }
        }

        protected void btnDaoChu_Click(object sender, EventArgs e)
        {
            toExecl1(Panel1, Label1.Text + "业务明细" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Millisecond.ToString());
        }
    }
}